<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<HEAD>
<TITLE>My Calendar</TITLE>
<META content="text/html; charset=UTF-8" http-equiv="Content-Type">
<LINK rel="stylesheet" type="text/css" href="${ctx}/resources/jsp/main.css">
<LINK rel="stylesheet" type="text/css" href="${ctx}/resources/jsp/dailog.css">
<LINK rel="stylesheet" type="text/css" href="${ctx}/resources/jsp/calendar.css">
<LINK rel="stylesheet" type="text/css" href="${ctx}/resources/jsp/dp.css">
<LINK rel="stylesheet" type="text/css" href="${ctx}/resources/jsp/alert.css">
<META name="GENERATOR" content="MSHTML 9.00.8112.16443">
</HEAD>
<BODY>

	<DIV>
		<DIV style="padding-right: 1px; padding-left: 1px;" id="calhead">
			<DIV class="cHead">
				<DIV class="ftitle">My Calendar</DIV>
				<DIV style="display: none;" id="loadingpannel"
					class="ptogtitle loadicon">Loading data...</DIV>
				<DIV style="display: none;" id="errorpannel"
					class="ptogtitle loaderror">Defaulterrormsg</DIV>
			</DIV>
			<DIV id="caltoolbar" class="ctoolbar">
				<DIV id="faddbtn" class="fbutton">
					<DIV>
						<SPAN class="addcal" title="Click to Create New Event">New
							Event</SPAN>
					</DIV>
				</DIV>
				<DIV class="btnseparator"></DIV>
				<DIV id="showtodaybtn" class="fbutton">
					<DIV>
						<SPAN class="showtoday" title="Click to back to today ">
							Today</SPAN>
					</DIV>
				</DIV>
				<DIV class="btnseparator"></DIV>
				<DIV id="showdaybtn" class="fbutton">
					<DIV>
						<SPAN class="showdayview" title="Day">Day</SPAN>
					</DIV>
				</DIV>
				<DIV id="showweekbtn" class="fbutton fcurrent">
					<DIV>
						<SPAN class="showweekview" title="Week">Week</SPAN>
					</DIV>
				</DIV>
				<DIV id="showmonthbtn" class="fbutton">
					<DIV>
						<SPAN class="showmonthview" title="Month">Month</SPAN>
					</DIV>
				</DIV>
				<DIV class="btnseparator"></DIV>
				<DIV id="showreflashbtn" class="fbutton">
					<DIV>
						<SPAN class="showdayflash" title="Refresh view">Refresh</SPAN>
					</DIV>
				</DIV>
				<DIV class="btnseparator"></DIV>
				<DIV id="sfprevbtn" class="fbutton" title="Prev">
					<SPAN class="fprev"></SPAN>
				</DIV>
				<DIV id="sfnextbtn" class="fbutton" title="Next">
					<SPAN class="fnext"></SPAN>
				</DIV>
				<DIV class="fshowdatep fbutton">
					<DIV>
						<INPUT id="hdtxtshow" name="txtshow" type="hidden"><SPAN
							id="txtdatetimeshow">Loading</SPAN>
					</DIV>
				</DIV>
				<DIV class="btnseparator"></DIV>
				<DIV class="clear"></DIV>
			</DIV>
		</DIV>
		<DIV style="padding: 1px;">
			<DIV class="t1 chromeColor">&nbsp;</DIV>
			<DIV class="t2 chromeColor">&nbsp;</DIV>
			<DIV id="dvCalMain" class="calmain printborder">
				<DIV style="overflow-y: visible;" id="gridcontainer"></DIV>
			</DIV>
			<DIV class="t2 chromeColor">&nbsp;</DIV>
			<DIV class="t1 chromeColor">&nbsp;</DIV>
		</DIV>
	</DIV>
	<SCRIPT type="text/javascript" src="${ctx}/resources/jsp/jquery-1.8.3.js"></SCRIPT>

	<SCRIPT type="text/javascript" src="${ctx}/resources/jsp/Common.js"></SCRIPT>

	<SCRIPT type="text/javascript" src="${ctx}/resources/jsp/blackbird.js"></SCRIPT>

	<SCRIPT type="text/javascript" src="${ctx}/resources/jsp/datepicker_lang_en_AU.js"></SCRIPT>

	<SCRIPT type="text/javascript" src="${ctx}/resources/jsp/jquery.datepicker.js"></SCRIPT>

	<SCRIPT type="text/javascript" src="${ctx}/resources/jsp/jquery.alert.js"></SCRIPT>

	<SCRIPT type="text/javascript" defer="defer" src="${ctx}/resources/jsp/jquery.ifrmdailog.js"></SCRIPT>

	<SCRIPT type="text/javascript" src="${ctx}/resources/jsp/xgcalendar_lang_en_AU.js"></SCRIPT>

	<SCRIPT type="text/javascript" src="${ctx}/resources/jsp/jquery.calendar.js"></SCRIPT>

	<SCRIPT type="text/javascript">
		$(document).ready(
				function() {
					/**
					var date1 = new Date(2012, 11, 6, 11, 0, 0, 0);
					var date2 = new Date(2012, 11, 6, 13, 0, 0, 0);
					var date3 = new Date(2012, 11, 7, 14, 0, 0, 0);
					var date4 = new Date(2012, 11, 7, 18, 0, 0, 0);
					//[id,title,start,end，全天日程，跨日日程,循环日程,theme,'','']
					
					var __CURRENTDATA = [
							[ '6234', 'hello', date1, date2, 0, 0, 0, 2, 1, 'shanghai',
									'' ],
							[ '6234', 'english', date3, date4, 0, 0, 0, 12, 1, 'beijing',
									'' ] ];
					**/
					var view = "week";
					var op = {
						view : view,
						weekstartday: 7,
						theme : 3,
						showday : new Date(),
						EditCmdhandler : Edit,
						DeleteCmdhandler : Delete,
						ViewCmdhandler : View,
						onWeekOrMonthToDay : wtd,
						onBeforeRequestData : cal_beforerequest,
						onAfterRequestData : cal_afterrequest,
						onRequestDataError : cal_onerror,
						url : "${ctx}/calendar!getPersonalCalendarData.action",
						quickAddUrl : "${ctx}/calendar!quickAddPersonalCal.action",
						quickUpdateUrl : "${ctx}/calendar!quickUpdatePersonalCal.action",
						quickDeleteUrl : "${ctx}/calendar!quickDeletePersonalCal.action" //快速删除日程的
					/* timeFormat:" hh:mm t", //t表示上午下午标识,h 表示12小时制的小时，H表示24小时制的小时,m表示分钟
					 tgtimeFormat:"ht" //同上 */
					};
					var $dv = $("#calhead");
					var _MH = document.documentElement.clientHeight;
					var dvH = $dv.height() + 2;
					op.height = _MH - dvH;
					//op.eventItems = __CURRENTDATA;

					var p = $("#gridcontainer").bcalendar(op).BcalGetOp();
					$("#gridcontainer").BCalReload();
					if (p && p.datestrshow) {
						$("#txtdatetimeshow").text(p.datestrshow);
					}
					$("#caltoolbar").noSelect();

					$("#hdtxtshow").datepicker(
							{
								picker : "#txtdatetimeshow",
								showtarget : $("#txtdatetimeshow"),
								onReturn : function(r) {
									var p = $("#gridcontainer").BCalGoToday(r)
											.BcalGetOp();
									if (p && p.datestrshow) {
										$("#txtdatetimeshow").text(
												p.datestrshow);
									}
								}
							});
					function cal_beforerequest(type) {
						var t = "正在加载数据...";
						switch (type) {
						case 1:
							t = "正在加载数据...";
							break;
						case 2:
						case 3:
						case 4:
							t = "正在处理请求...";
							break;
						}
						$("#errorpannel").hide();
						$("#loadingpannel").html(t).show();
					}
					function cal_afterrequest(type) {
						switch (type) {
						case 1:
							$("#loadingpannel").hide();
							break;
						case 2:
						case 3:
						case 4:
							$("#loadingpannel").html("操作成功!");
							window.setTimeout(function() {
								$("#loadingpannel").hide();
							}, 2000);
							break;
						}

					}
					function cal_onerror(type, data) {
						$("#errorpannel").show();
					}
					function Edit(data) {
						var eurl = "";
						if (data) {
							var url = StrFormat(eurl, data);
							OpenModelWindow(url, {
								width : 600,
								height : 400,
								caption : "管理日程",
								onclose : function() {
									$("#gridcontainer").BCalReload();
								}
							});
						}
					}
					function View(data) {
						var vurl = "";
						if (data) {
							var url = StrFormat(vurl, data);
							OpenModelWindow(url, {
								width : 600,
								height : 400,
								caption : "查看日程"
							});
						}
					}
					function Delete(data, callback) {
						$.alerts.okButton = "确定";
						$.alerts.cancelButton = "取消";
						hiConfirm("是否要删除该日程?", '确认', function(r) {
							r && callback(0);
						});
					}
					function wtd(p) {
						if (p && p.datestrshow) {
							$("#txtdatetimeshow").text(p.datestrshow);
						}
						$("#caltoolbar div.fcurrent").each(function() {
							$(this).removeClass("fcurrent");
						})
						$("#showdaybtn").addClass("fcurrent");
					}
					//显示日视图
					$("#showdaybtn").click(
							function(e) {
								//document.location.href="#day";
								$("#caltoolbar div.fcurrent").each(function() {
									$(this).removeClass("fcurrent");
								})
								$(this).addClass("fcurrent");
								var p = $("#gridcontainer").BCalSwtichview(
										"day").BcalGetOp();
								if (p && p.datestrshow) {
									$("#txtdatetimeshow").text(p.datestrshow);
								}
							});
					//显示周视图
					$("#showweekbtn").click(
							function(e) {
								//document.location.href="#week";
								$("#caltoolbar div.fcurrent").each(function() {
									$(this).removeClass("fcurrent");
								})
								$(this).addClass("fcurrent");
								var p = $("#gridcontainer").BCalSwtichview(
										"week").BcalGetOp();
								if (p && p.datestrshow) {
									$("#txtdatetimeshow").text(p.datestrshow);
								}

							});
					//显示月视图
					$("#showmonthbtn").click(
							function(e) {
								//document.location.href="#month";
								$("#caltoolbar div.fcurrent").each(function() {
									$(this).removeClass("fcurrent");
								})
								$(this).addClass("fcurrent");
								var p = $("#gridcontainer").BCalSwtichview(
										"month").BcalGetOp();
								if (p && p.datestrshow) {
									$("#txtdatetimeshow").text(p.datestrshow);
								}
							});

					$("#showreflashbtn").click(function(e) {
						$("#gridcontainer").BCalReload();
					});

					//点击新增日程
					$("#faddbtn").click(function(e) {
						var url = "";
						OpenModelWindow(url, {
							width : 500,
							height : 400,
							caption : "新增日程"
						});
					});
					//点击回到今天
					$("#showtodaybtn").click(function(e) {
						var p = $("#gridcontainer").BCalGoToday().BcalGetOp();
						if (p && p.datestrshow) {
							$("#txtdatetimeshow").text(p.datestrshow);
						}

					});
					//上一个
					$("#sfprevbtn").click(function(e) {
						var p = $("#gridcontainer").BCalPrev().BcalGetOp();
						if (p && p.datestrshow) {
							$("#txtdatetimeshow").text(p.datestrshow);
						}

					});
					//下一个
					$("#sfnextbtn").click(function(e) {
						var p = $("#gridcontainer").BCalNext().BcalGetOp();
						if (p && p.datestrshow) {
							$("#txtdatetimeshow").text(p.datestrshow);
						}
					});
					$("#changetochinese").click(function(e) {
						location.href = "?lang=zh-cn";
					});
					$("#changetoenglish").click(function(e) {
						location.href = "?lang=en-us";
					});
					$("#changetoenglishau").click(function(e) {
						location.href = "?lang=en-au";
					});

				});
	</SCRIPT>
</BODY>
</HTML>
